package com.haibei.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.common.cache.SimpleImgLoaderLru;
import com.haibei.R;
import com.haibei.adapter.bean.HotGoodsBanner;

public class HotGoodsAdapter extends BaseAdapter {

	private Context context;
	private ArrayList<HotGoodsBanner> mArrayListDataBanner;

	public HotGoodsAdapter(Context context, ArrayList<HotGoodsBanner> hots) {
		this.context = context;
		this.mArrayListDataBanner = hots;
	}

	@Override
	public int getCount() {
		return mArrayListDataBanner.size();
	}

	@Override
	public Object getItem(int position) {
		return mArrayListDataBanner.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vl = null;
		if (null == convertView) {
			convertView = View.inflate(context, com.haibei.R.layout.item_hot_goods, null);
			vl = new ViewHolder();
			vl.imgView = (ImageView) convertView.findViewById(R.id.imageView);
			convertView.setTag(vl);
		} else {
			vl = (ViewHolder) convertView.getTag();
		}
		HotGoodsBanner p = mArrayListDataBanner.get(position);
		// vl.imgView
		SimpleImgLoaderLru.from(context).displayImage(vl.imgView, p.getBannerImg(), R.drawable.bg_default_market);
		return convertView;
	}

	class ViewHolder {
		ImageView imgView;
	}
}
